package com.example.boot.service

import com.example.boot.domain.Settings
import com.example.boot.domain.SettingsV2
import com.example.boot.repository.SettingsRepository
import com.example.boot.repository.SettingsRepositoryV2
import com.example.boot.repository.SettingsRepositoryV3
import com.example.boot.utils.CurrentFacade
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import java.math.BigInteger

@Service
class SettingsServiceImpl @Autowired constructor(
    val settingsRepository: SettingsRepository,
    val settingsRepositoryV2: SettingsRepositoryV2,
    val settingsRepositoryV3: SettingsRepositoryV3,
    val currentFacade: CurrentFacade,
) : SettingsService {

    override fun createSettings(settings: Settings): Settings {
        return settingsRepository.save(settings)
    }

    override fun createSettingsV2(settingsV2: SettingsV2): SettingsV2 {


        settingsRepositoryV2.insertSettings(settingsV2.name, settingsV2.value)
        return settingsV2
    }

    override fun createSettingsV2WithId(settingsV2: SettingsV2): SettingsV2 {
        val id = settingsRepositoryV2.getId()
        settingsRepositoryV2.insertSettings(settingsV2.name, settingsV2.value, id)
        return SettingsV2(id, settingsV2.name, settingsV2.value)
    }

    override fun createSettingsV3(settingsV2: SettingsV2): SettingsV2 {
//        settingsRepositoryV3.insertSettings(settingsV2)
        settingsRepositoryV3.insertSettings2(settingsV2)
        return settingsV2
    }
}